﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestesFixacao.Dominio.Modelos;

namespace TestesFixacao.Dominio.Writers
{
    public class AlternativaWriter : IConvertible<List<Alternativa>>
    {
        public void Convert(System.Xml.XmlTextWriter writer, List<Alternativa> alternativas)
        {
            writer.WriteStartElement("alternativas");

            foreach (var item in alternativas)
            {
                writer.WriteStartElement("alternativa");

                writer.WriteElementString("letra", item.Letra.ToString());
                writer.WriteElementString("resposta", item.Resposta);
                writer.WriteElementString("correta", item.Correta.ToString());

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
    }
}